{php include wl_template('common/header');}
<ul class="nav nav-tabs">
	<li class="active"><a href="#">运营统计</a></li>
</ul>
<div class="app-content">
	<div class="app-filter">
		<div class="filter-list">
			<form action="{if is_agent()}./cityagent.php{else}./index.php{/if}" method="get" class="form-horizontal" id="form1">
				{if !is_agent()}
				<input type="hidden" name="c" value="site" />
	            <input type="hidden" name="a" value="entry" />
	            <input type="hidden" name="m" value="{MODULE_NAME}" />
	            {/if}
	            <input type="hidden" name="p" value="{$_W['plugin']}" />
				<input type="hidden" name="ac" value="{$_W['controller']}" />
				<input type="hidden" name="do" value="{$_W['method']}" />
				<input type="hidden" name="days" value="{$days}"/>
				<div class="form-group">
					<label class="col-sm-2 control-label">时间</label>
					<div class="col-sm-9 js-daterange" data-form="#form1">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('days:0');}" class="btn {if $days == 0}btn-primary{else}btn-default{/if}">今天</a>
							<a href="{php echo wl_filter_url('days:6');}" class="btn {if $days == 6}btn-primary{else}btn-default{/if}">最近7天</a>
							<a href="{php echo wl_filter_url('days:29');}" class="btn {if $days == 29}btn-primary{else}btn-default{/if}">最近30天</a>
							<a href="javascript:;" class="btn js-btn-custom {if $days == -1}btn-primary{else}btn-default{/if}">自定义</a>
						</div>
						<span class="btn-daterange js-btn-daterange {if $days != -1}hide{/if}">
							{php echo tpl_select_time_info('stat_day', array('start' => $selstarttime, 'end' => $selendtime));}
						</span>
					</div>
				</div>
				<div class="form-group form-inline">
					<label class="col-sm-2 control-label">其他</label>
					<div class="col-sm-9">
						<select name="sid" class="form-control select2 js-select2 width-130" id="select-sid">
							<option value="0" {if !$sid}selected{/if}>全部门店</option>
							{loop $stores $store}
								<option value="{$store['id']}" {if $store['id'] == $sid}selected{/if}>{$store['storename']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">排序</label>
					<div class="col-sm-9">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('orderby: money')}" class="btn {if $orderby == 'money'}btn-primary{else}btn-default{/if}">营业额</a>
							<a href="{php echo wl_filter_url('orderby: ordernum')}" class="btn {if $orderby == 'ordernum'}btn-primary{else}btn-default{/if}">订单量</a>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
	
	<div class="panel panel-stat">
		<div class="panel-heading">
			<h3>总览</h3>
		</div>
		<div class="panel-body">
			<div class="col-md-3">
				<div class="title">
					营业总额(元)
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-all-fee">￥--</span>
					</a>
				</div>
			</div>
			<div class="col-md-3">
				<div class="title">
					总订单
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-all-order">--</span>
					</a>
				</div>
			</div>
		</div>
		<div class="panel-body">
			<div class="col-md-2">
				<div class="title">
					抢购支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-rush-fee">￥--</span>
					</a>
					<span class="info" id="html-total-rush-order">--</span>
				</div>
			</div>
			{if p('wlfightgroup')}
			<div class="col-md-2">
				<div class="title">
					拼团支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-fight-fee">￥--</span>
					</a>
					<span class="info" id="html-total-fight-order">--</span>
				</div>
			</div>
			{/if}
			{if p('wlcoupon')}
			<div class="col-md-2">
				<div class="title">
					卡券支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-coupon-fee">￥--</span>
					</a>
					<span class="info" id="html-total-coupon-order">--</span>
				</div>
			</div>
			{/if}
			{if p('groupon')}
			<div class="col-md-2">
				<div class="title">
					团购支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-groupon-fee">￥--</span>
					</a>
					<span class="info" id="html-total-groupon-order">--</span>
				</div>
			</div>
			{/if}
			{if p('bargain')}
			<div class="col-md-2">
				<div class="title">
					砍价支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-bargain-fee">￥--</span>
					</a>
					<span class="info" id="html-total-bargain-order">--</span>
				</div>
			</div>
			{/if}
			{if p('citydelivery')}
			<div class="col-md-2">
				<div class="title">
					同城配送支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-citydelivery-fee">￥--</span>
					</a>
					<span class="info" id="html-total-citydelivery-order">--</span>
				</div>
			</div>
			{/if}
			{if p('activity')}
			<div class="col-md-2">
				<div class="title">
					活动支付金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-activity-fee">￥--</span>
					</a>
					<span class="info" id="html-total-activity-order">--</span>
				</div>
			</div>
			{/if}
			<div class="col-md-2">
				<div class="title">
					在线买单金额
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-payonline-fee">￥--</span>
					</a>
					<span class="info" id="html-total-payonline-order">--</span>
				</div>
			</div>
		</div>
	</div>
	
	<div class="panel panel-trend">
		<div class="panel-heading">
			<h3>趋势图</h3>
		</div>
		<div class="panel-body">
			<div id="chart-order-holder" style="width: 100%;height:400px;"></div>
		</div>
	</div>
	
	<div class="app-table-list">
		<div class="table-responsive">
			<table class="table table-bordered table-hover">
				<thead class="navbar-inner">
					<tr>
						<th>排名</th>
						<th>商户</th>
						<th>订单量</th>
						<th>订单量占比</th>
						<th>营业额</th>
						<th>营业额占比</th>
						<!--<th class="text-right">操作</th>-->
					</tr>
				</thead>
				<tbody id="storelist">
				</tbody>
			</table>
		</div>
	</div>
</div>
<script>
	
$(function(){
	myrequire(['g2','data-set'],function(){
		$.post(location.href, function(stat){
			var data = $.parseJSON(stat);
			var chart = new G2.Chart({
			  	container: 'chart-order-holder',
			  	forceFit: true,
			  	height: 500
			});
			chart.source(data.list);
			chart.scale('数据', {});
			chart.interval().position('year*数据');
			chart.render();
			
			$('#html-all-fee').html('￥'+data.allmoney);
			$('#html-total-all-order').html(data.allorder);
			
			$('#html-total-rush-fee').html('￥'+data.rushmoney);
			$('#html-total-rush-order').html('订单数：'+data.rushorder);
			$('#html-total-fight-fee').html('￥'+data.fightmoney);
			$('#html-total-fight-order').html('订单数：'+data.fightorder);
			$('#html-total-coupon-fee').html('￥'+data.couponmoney);
			$('#html-total-coupon-order').html('订单数：'+data.couponorder);
			$('#html-total-groupon-fee').html('￥'+data.groupmoney);
			$('#html-total-groupon-order').html('订单数：'+data.grouponorder);
			$('#html-total-bargain-fee').html('￥'+data.barmoney);
			$('#html-total-bargain-order').html('订单数：'+data.barorder);
			$('#html-total-citydelivery-fee').html('￥'+data.citydeliverymoney);
			$('#html-total-citydelivery-order').html('订单数：'+data.citydeliveryorder);
			$('#html-total-activity-fee').html('￥'+data.actmoney);
			$('#html-total-activity-order').html('订单数：'+data.actorder);
			$('#html-total-payonline-fee').html('￥'+data.paymoney);
			$('#html-total-payonline-order').html('订单数：'+data.payorder);
			//表格
			var hh='';
			var lenth = data.storelist.length;
			for (var i=0;i < data.storelist.length;i++) {
				var rank = i+1;
				hh += '<tr>';
				hh += '<td><strong>'+rank+'</strong></td>';
				hh += '<td><strong>'+data.storelist[i].name+'</strong></td>';
				hh += '<td><span class="text-danger">'+data.storelist[i].order+'</span></td>';
				hh += '<td><span class="text-danger">'+data.storelist[i].orderrate+'%</span></td>';
				hh += '<td><span class="text-success">￥'+data.storelist[i].money+'</span></td>';
				hh += '<td><span class="text-success">'+data.storelist[i].moneyrate+'%</span></td>';
				hh += '</tr>';
			}
			$('#storelist').html(hh);
		});
	});
});
	
</script>
{php include wl_template('common/footer');}